using System;
using System.Collections.ObjectModel;
using CodeMinder.SCM.Interface;
using SharpSvn;

namespace CodeMinder.SCM.SVN
{
    public class SvnSourceControlProvider
    {
        public void Poc()
        {
            var url = new Uri(@"https://subversion.assembla.com/svn/tipestate");
            
            var client = new SvnClient();
            var range = new SvnRevisionRange(
                new SvnRevision(DateTime.Now.AddMonths(-1)), 
                new SvnRevision(DateTime.Now.AddMonths(1)));

            var args = new SvnLogArgs
                           {
                               //Limit = 100,
                               //RetrieveAllProperties = false,
                               //Range = range,
                               //RetrieveChangedPaths = false,
                               //RetrieveMergedRevisions = false,
                           };
            
            Collection<SvnLogEventArgs> results;
            client.GetLog(url, args, out results);
            
            foreach (var result in results)
            {
                Console.WriteLine(result.Revision);
                Console.WriteLine(result.Author);
                Console.WriteLine(result.Time);
                Console.WriteLine(result.LogMessage);

                foreach (var changedPath in result.ChangedPaths)
                {
                    Console.WriteLine(string.Format("-- {0} on {1} at {2}", 
                        changedPath.Action, 
                        changedPath.NodeKind,
                        changedPath.Path));
                }
            }

            client.Dispose();
        }
    }
}